home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / 80x0992d.zip / COPRTEST.C < prev    next >
C/C++ Source or Header  |  1992-09-30  |  1KB  |  38 lines

  1. /*
  2. **  coprtest.c
  3. **  By: Doug Mansell
  4. **  Re: VGA palette changing
  5. **  Link copper.asm with coprtest.c for a little demo...
  6. */
  7.  
  8. #include <math.h>
  9.  
  10. #define SCREENLINES 400             /* suitable for 80x25 text */
  11. #define PALSIZE SCREENLINES+1
  12.  
  13. struct _rgb {
  14.     unsigned char red, green, blue;
  15. } cols[PALSIZE];
  16.  
  17. void pascal copper(int lines, unsigned char DACnum,
  18.                    void *colours, int count);
  19.  
  20. void main()
  21. {
  22.     int loop;
  23.     double x, phase;
  24.  
  25.     /* construct a pretty rainbow colour palette */
  26.     phase = 2 * M_PI / 3;
  27.     for (loop = 0; loop < PALSIZE; loop++) {
  28.         x = 2 * M_PI * loop / PALSIZE;
  29.         cols[loop].red = 32 * sin(x) + 31;
  30.         cols[loop].green = 32 * sin(x+ phase) + 31;
  31.         cols[loop].blue = 32 * sin(x+ 2*phase) + 31;
  32.     }
  33.     /* hold the palette steady for 500 screen refreshes :-) */
  34.     copper(SCREENLINES, 0 ,cols, 500);
  35.     puts("press a key to roll it up the screen"); getch();
  36.     copper(SCREENLINES - 1, 0, cols, 500);
  37. } /* EOF COPRTEST.C */
  38.